package com.yitiao.multithread;

import java.util.concurrent.TimeUnit;

/**
 * 可重入锁
 *  - 显式
 *  - 隐式
 */
public class ReEntryDemo {
    static final Object obj=new Object();
    public static void main(String[] args) throws InterruptedException {
        new Thread(()->{
            synchronized (obj){

                try {
                    TimeUnit.SECONDS.sleep(2);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("------------1");
                synchronized (obj){
                    System.out.println("-------------2");
                    synchronized (obj){
                        System.out.println("---------3");
                    }
                }
            }
        }).start();

    }
}
